// 自定义中间件进行验证  
const validateRequest = (schema, obj) => {  
    return async (req, res, next) => {  
        const { error } = schema.validate(req[obj]);  
        if (error) {  
            const errorMessage = error.details.map((detail) => detail.message).join(', ');  
            return res.onError(errorMessage);  
        }  
        next();  
    };  
}; 

module.exports = {
    validateRequest
}
  